package com.sugar.follow.up.module.business.controller.app.record.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.sugar.follow.up.module.business.dal.dataobject.questionnairetemplatequestion.dto.OptionDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

import static com.sugar.follow.up.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

@Schema(description = "APP - 记录 Response VO")
@Data
public class AppRecordDetailRespVO {

    @Schema(description = "记录ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "8308")
    private Long id;

    @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED)
    private String title;

    @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED)
    private String briefDescribe;

    @Schema(description = "是否完成", requiredMode = Schema.RequiredMode.REQUIRED)
    private Boolean isDone;

    @Schema(description = "完成时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @JsonSerialize(using = LocalDateTimeSerializer.class) // 序列化（响应）
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化（请求）
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime doneTime;

    @Schema(description = "题目", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<QuestionRespVO> questions;

    @Data
    public static class QuestionRespVO{

        @Schema(description = "题目ID", requiredMode = Schema.RequiredMode.REQUIRED)
        private Long id;

        @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED)
        private String title;

        @Schema(description = "提示语", requiredMode = Schema.RequiredMode.REQUIRED)
        private String tip;

        @Schema(description = "题型（0单选 1多选 2填空 3问答 4日期））", requiredMode = Schema.RequiredMode.REQUIRED)
        private Integer type;

        @Schema(description = "题目选项", requiredMode = Schema.RequiredMode.REQUIRED)
        private List<OptionDTO> options;

        @Schema(description = "用户答案", requiredMode = Schema.RequiredMode.REQUIRED)
        private String answer;
    }
}
